package java基础.method;

/**
 * @author IT_Jay
 * @date 2022/1/5 9:38 AM
 */
public class Demo02 {
    public static void main(String[] args) {
        int result = max(2,4);
        System.out.println(result);
        System.out.println(max(4,4));
        System.out.println(max(9.9,9.9));
        System.out.println(max(3,3,3));
    }

    //比大小 int
    public static int max(int num1,int num2){
        int result ;
        if (num1 > num2){
            result = num1;
        }else {result = num2;}
        if (num1==num2){
            System.out.println("num1==num2");
            return 0;       //终止方法
        }

        return result;
    }
    //比大小 double
//    public static double max(double num1,double num2){
//        double result ;
//        if (num1 > num2){
//            result = num1;
//        }else {result = num2;}
//        if (num1==num2){
//            System.out.println("num1==num2");
//            return 0;       //终止方法
//        }
//
//        return result;
//    }

    //转型 和上面注释部分只能同时写一个
    public static int max(double num1,double num2){
        int result=0 ;
        if (num1 > num2){
            result = (int)num1;
        }else {
            result = (int)num2;
        }
        if (num1==num2){
            System.out.println("num1==num2");
            return 0;       //终止方法
        }

        return result;
    }

    //三个
    public static int max(int num1,int num2, int num3){
        int result = 0;
        if (num1 > num2 && num1>num3){
            result = num1;
        }else if(num2>num1 && num2>num3){
            result = num2;
        }else if (num3>num1 && num3>num2){
            result=num3;
        }
        else{
            System.out.println("num1==num2==num3");
            return 0;       //终止方法
        }

        return result;
    }
}
